package com.payment.system.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.payment.common.base.AjaxResult;
import com.payment.common.support.Convert;
import com.payment.common.utils.StringUtils;
import com.payment.system.domain.MerchantDay;
import com.payment.system.mapper.MerchantDayMapper;
import com.payment.system.service.IMerchantDayService;
import com.payment.system.vo.DayMonthVo;

/**
 * 日统计 服务层实现
 * 
 * @author payment
 * @date 2019-03-07
 */
@Service
public class MerchantDayServiceImpl implements IMerchantDayService 
{

	@Autowired
	private MerchantDayMapper merchantDayMapper;

	/**
     * 查询日统计信息
     * 
     * @param id 日统计ID
     * @return 日统计信息
     */
    @Override
	public MerchantDay selectMerchantDayById(Long id)
	{
	    return merchantDayMapper.selectMerchantDayById(id);
	}
	
	/**
     * 查询日统计列表
     * 
     * @param merchantDay 日统计信息
     * @return 日统计集合
     */
	@Override
	public List<MerchantDay> selectMerchantDayList(MerchantDay merchantDay)
	{
	    return merchantDayMapper.selectMerchantDayList(merchantDay);
	}
	
    /**
     * 新增日统计
     * 
     * @param merchantDay 日统计信息
     * @return 结果
     */
	@Override
	public int insertMerchantDay(MerchantDay merchantDay)
	{
	    return merchantDayMapper.insertMerchantDay(merchantDay);
	}
	
	/**
     * 修改日统计
     * 
     * @param merchantDay 日统计信息
     * @return 结果
     */
	@Override
	public int updateMerchantDay(MerchantDay merchantDay)
	{
	    return merchantDayMapper.updateMerchantDay(merchantDay);
	}

	/**
     * 删除日统计对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteMerchantDayByIds(String ids)
	{
		return merchantDayMapper.deleteMerchantDayByIds(Convert.toStrArray(ids));
	}
	
	@Override
	public MerchantDay selectMerchantDayByMerchantIdAndTime(String id, String time) {
		// TODO Auto-generated method stub
		return merchantDayMapper.selectMerchantDayByIdAndDate(id, time+" 00:00:00", time+" 23:59:59");
	}

	@Override
	public AjaxResult selectMerchantDayListByMerchantId(Integer pageNum, Integer pageSize, String merchantId) {
		if(pageNum==null||pageSize==null|| StringUtils.isEmpty(merchantId)){
			return  AjaxResult.error(1,"缺失必要参数");
		}
		List<DayMonthVo> list=merchantDayMapper.selectMerchantDayListByMerchantId(pageNum*pageSize,pageSize,merchantId);
		return AjaxResult.successAndData("成功",list);
	}
}
